package com.woniuxy.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

@Data
@NoArgsConstructor
public class Book implements Serializable {
    private Integer id; //编号
    private String title; //书名
    private Double price; //价格
    private String publisher; //出版社
    private LocalDate publishDate; //出版日期
    private String author; //作者

    @TableLogic(delval = "1",value = "0")//这是一个逻辑删除的字段
    private Integer deleted=0;

    @Version //这个字段用于版本控制
    private Integer version =0;

    @TableField(fill = FieldFill.INSERT)//在插入操作的时候填充
    private Date createTime; //创建时间
    @TableField(fill = FieldFill.INSERT_UPDATE)//插入和更新时填充
    private Date updateTime; //更新时间

    public Book(Integer id, String title, Double price, String publisher,
                LocalDate publishDate, String author) {
        this.id = id;
        this.title = title;
        this.price = price;
        this.publisher = publisher;
        this.publishDate = publishDate;
        this.author = author;
    }
}